/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  StyleSheet,
  View,
  TouchableHighlight,
  Image,
  ScrollView,
  Text
} from 'react-native';
import HttpAxios from '../../utils/HttpAxios';
import ViewUtils from '../../utils/ViewUtils';
import GlobalStyles from '../../assets/css/GlobalStyles';

export default class MyPage extends Component {
  static navigationOptions = ({navigation})=>{
    const params = navigation.state.params || {};
    return {
      headerTitle:params.title?params.title:'我的',
      headerStyle:{
        backgroundColor:'#111111',
      },
      headerTintColor:'#fff',
      headerTitleStyle:{
        fontWeight:'bold',
      }
    }
  };
  constructor(props){
    super(props);
    this.state={
      result:'',
    }

  }
  getInfo(url){
    HttpAxios.get('/1220562')
      .then(function (response) {
        alert(JSON.stringify(response));
      })
      .catch(function (error) {
        alert(error);
      });

  }
  _onPressButton(tag){
    //const {navigation} = this.props;
    this.props.navigation.navigate('Intructor',{
      component:routeMy,
      params:123,
    })
    return;
    //alert(tag);
    var routeMy;
    switch (tag){
      case 'Me':
      routeMy = 'Intructor';
      break;
    }
    
    if(routeMy){
      const {navigation} = this.props;
      navigation.navigate.push(routeMy,{
        component:routeMy,
        params:123,
      })
    }
  }
  render() {
    const {navigation} = this.props;
    return (
      
      <ScrollView contentContainerStyle={GlobalStyles.root_container}>
        <TouchableHighlight onPress={()=>this._onPressButton()}>
          
            <View style={styles.items}>
              <Image style={styles.leftImages} source={require('../../assets/images/group.png')} />
              <Text >第一导航</Text>
              <Image style={styles.rightImage} source={require('../../assets/images/right.png')} />

            </View>
         </TouchableHighlight>
         
           <Text style={styles.groupTitle}>
             全局样式列表
           </Text>
         {ViewUtils.getSettingItem(
           ()=>this._onPressButton('Me'),
           require('../../assets/images/group.png'),
           '第二个导航页面',

         )}
      </ScrollView>
      
    );
  }
}

const styles = StyleSheet.create({
  container: {
    //flex:1,
    backgroundColor: '#F5FCFF',
  },
  item:{
    flexDirection:'row',
    justifyContent:'space-between',
    height:60,
    borderWidth: 1,
    //border:1,
    borderColor: '#dd99dd'
  },
  items:{ 
    justifyContent:'space-between',
    flexDirection:'row',
    alignItems:'center',
  },
  leftImages:{
    width:40,
    height:40,
    marginLeft:10,
  },
  rightImage:{
    marginRight:  10,
    width:22,
    height: 22,
  },

  groupTitle:{
    marginLeft:10,
    marginTop:10,
    marginBottom:5,
    fontSize:12,
    color:'gray'
  }
});
